import request from '@/utils/request'

// 获得图书列表
export const getBookList = (params: any) => {
    return request({
      method: 'get',
      url: `/api/mini-library/books/list`,
      params,
    })
  }


//获取借阅书籍记录
export const getRecord = (params: any) => {
  return request({
    method: 'get',
    url: `/api/mini-library/records`,
    params,
  })
}

//查询借阅日志
export const getRecords = (params: any) => {
  return request({
    method: 'get',
    url: `/api/mini-library/records/all`,
    params,
  })
}

//下架图书
export const deleteBook = (bookId: any) => {
  return request({
    method: 'delete',
    // 使用模板字符串将bookId插入到URL中
    url: `/api/mini-library/books/${bookId}`,
    // 由于bookId直接插入到URL中，params在这里是不需要的
  });
}

export const returnBook = (bookId: any) => {
  return request({
    method: 'put',
    // 使用模板字符串将bookId插入到URL中
    url: `/api/mini-library/return/${bookId}`,
  });
}

// 借书
export const borrowBook = (bookId: any) => {
  return request({
    method: 'post',
    url: `/api/mini-library/borrow/${bookId}`,
  })
}

export const addBook = (data: any) => {
  return request({
    method: 'post',
    url: `/api/mini-library/books/`,
    data,
  })
}
export const editBook = (data: any) => {
  return request({
    method: 'put',
    url: `/api/mini-library/books/`,
    data,
  })
}
//查询借阅日志
export const getUsers = () => {
  return request({
    method: 'get',
    url: `/api/mini-library/username/all`,

  })
}
